package com.telecom.controller.admin;

import com.telecom.common.convention.result.Result;
import com.telecom.pojo.dto.admin.work.QueryDailyOrderStatisticsDTO;
import com.telecom.pojo.vo.admin.meal.MealRankingVO;
import com.telecom.pojo.vo.admin.workspace.BusinessDataVO;
import com.telecom.pojo.vo.admin.workspace.OrderOverViewVO;
import com.telecom.service.WorkspaceService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 工作台接口
 */
@RestController
@RequestMapping("/admin/workspace")
@Slf4j
public class WorkspaceController {

    @Resource
    WorkspaceService workspaceService;

    /**
     * 查询今日运营数据
     * 
     * @return 运营数据
     */
    @GetMapping("/businessData")
    public Result<BusinessDataVO> getBusinessData() {
        log.info("管理端查询今日运营数据");
        BusinessDataVO businessData = workspaceService.getBusinessData();
        return Result.success(businessData);
    }

    /**
     * 查询某日订单统计数据
     * 
     * @return 订单统计数据
     */
    @GetMapping("/overviewOrders")
    public Result<List<OrderOverViewVO>> getOrderOverview(QueryDailyOrderStatisticsDTO queryDailyOrderStatisticsDTO) {
        log.info("管理端查询今日订单统计数据");
        List<OrderOverViewVO> orderOverview = workspaceService.getOrderOverview(queryDailyOrderStatisticsDTO);
        return Result.success(orderOverview);
    }


    /**
     * 获取热门套餐排行
     *
     * <p>该接口返回按照订购次数排序的热门套餐列表，默认返回前10条记录</p>
     *
     * @return 热门套餐排行列表
     */
    @GetMapping("/hot-meals")
    public Result<List<MealRankingVO>> getHotMealRanking() {
        log.info("管理端查询热门套餐排行");
        List<MealRankingVO> hotMealRanking = workspaceService.getHotMealRanking();
        return Result.success(hotMealRanking);
    }
}